package org.neurone.action.application;

import org.neurone.action.BaseActionSupport;
import org.neurone.application.impl.ApplicationFaceLocal;
import org.neurone.application.impl.ApplicationFaceLocalFactory;
import org.neurone.context.MessageConst;
import org.neurone.domain.Application;

public class ApplicationViewAction extends BaseActionSupport {
	private Long appid;
	private Application	app;
	
	private ApplicationFaceLocalFactory appFactory;

	public Long getAppid() {
		return appid;
	}

	public void setAppid(Long appid) {
		this.appid = appid;
	}

	public Application getApp() {
		return app;
	}

	public void setApp(Application app) {
		this.app = app;
	}

	public ApplicationFaceLocalFactory getAppFactory() {
		return appFactory;
	}

	public void setAppFactory(ApplicationFaceLocalFactory appFactory) {
		this.appFactory = appFactory;
	}
	
	public String viewApp()
	{
		ApplicationFaceLocal a = this.appFactory.getNewApplicationFace(this.appid);
		if(a.isPersistentAvailable())
		{
			this.app = a;
			return success();
		}
		else
		{
			this.addActionError(MessageConst.NO_SUCH_APPLICATION);
			return ERROR;
		}
		
	}
}
